#include <iostream>

using namespace std;

int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool check1(int date)
{
	int year = date / 10000;
	int month = date / 100 % 100;
	int day = date % 100;
	
	if (day > months[month] || day == 0) return false;
	return true;
}

int ans = 0;

bool check2(int date)
{
	string s = to_string(date);
	
	int cnt = 1;
	
	for (int i = 1; i < s.size(); i ++ )
	{
		if (s[i] == s[i - 1] + 1)
		{
			cnt ++ ;
		}
		else 
		{
			cnt = 1;
			i ++ ;
		}
		
		if (cnt == 3) return true;
		
	}
	
	return false;
}

int main()
{
	cout << check2(20221230) << endl;
	
	for (int i = 20220101; i <= 20221231; i ++ )
	{
		if (!check1(i)) continue;
		
		if (check2(i)) 
		{
			ans ++ ;
			cout << i << endl;
		}
	}	
	
	cout << ans << endl;
	
	return 0;
}